/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package SysAguas.visao;

import SysAguas.controle.Erro;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Frame;

import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JDialog;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;

/**
 *
 * @author Diego uit
 */
public class DialogAtualizarReserva extends JDialog implements ActionListener, MouseListener {

    private JPanel p1, p2, p3, p11, p111, p2222, p4;
    private JButton atualizar, pesquisar, fechar, addquarto, retirarQ, listar;
    private JTextField nome22, sobrenome1, telefone1, endereço1, dataSA, dataEN,
            porcentagem1;
    private JLabel nome2, sobrenome, telefone, endereço, dataS,
            dataE, porcentagem, status;
    private JTable tquarto;
    private JCheckBox reservada, confirmada, cancelada;

    public DialogAtualizarReserva(Frame frame, String title, boolean modal) {

        super(frame, title, modal);

        p1 = new JPanel();
        p2 = new JPanel();
        p3 = new JPanel();
        p11 = new JPanel();

        p111 = new JPanel();

        p2222 = new JPanel();

        p4 = new JPanel();
        atualizar = new JButton("Atualizar");
        atualizar.addActionListener(new Erro());




        nome2 = new JLabel(" Nome ");
        sobrenome = new JLabel("Sobrenome");
        telefone = new JLabel("Telefone");
        endereço = new JLabel("Endereço ");
        dataS = new JLabel("Data de Saida");
        dataE = new JLabel("Data de Entrada");
        porcentagem = new JLabel("Porcentagem de Desconto");
        status = new JLabel("Status:");


        pesquisar = new JButton("Pesquisar Quarto");
        pesquisar.addActionListener(new Erro());
        fechar = new JButton("Fechar");
        fechar.addActionListener(this);
        addquarto = new JButton("Add Quarto");
        addquarto.addActionListener(new Erro());
        retirarQ = new JButton("Retirar Quarto");
        retirarQ.addActionListener(new Erro());
        listar = new JButton("Listar Quartos");
        listar.addActionListener(new Erro());


        nome22 = new JTextField(7);
        telefone1 = new JTextField(7);
        endereço1 = new JTextField(28);
        dataSA = new JTextField(7);
        dataEN = new JTextField(7);
        porcentagem1 = new JTextField(4);

        sobrenome1 = new JTextField(7);

        tquarto = new JTable(2, 6);
        tquarto.setModel(new javax.swing.table.DefaultTableModel(
                new Object[][]{
                    null, null, null, null, null, null,
                    null, null, null, null, null, null,},
                new String[]{
                    "Numero de Quarto", "Nome", "Capacidade", "Descrição", "Tipo", "Valor"
                }));


        reservada = new JCheckBox("Reservada");
        reservada.addMouseListener(this);
        confirmada = new JCheckBox("Confirmada");
        confirmada.addMouseListener(this);
        cancelada = new JCheckBox("Cancelada");
        cancelada.addMouseListener(this);



    }

    public void montaa() {


        this.setLayout(new BorderLayout(1, 1));
        this.setSize(650, 360);
        this.setResizable(false);


        this.add(p2222, BorderLayout.CENTER);
        p2222.setLayout(new GridLayout(3, 1));
        p2222.add(p1);
        p2222.add(p2);
        p2222.add(p3);

        p2222.setBorder(BorderFactory.createTitledBorder("Dados para atualização"));


        p1.setLayout(new BorderLayout());

        p1.add(p11, BorderLayout.NORTH);
        p11.setLayout(new FlowLayout(FlowLayout.LEFT));
        p11.add(nome2);
        p11.add(nome22);
        p11.add(sobrenome);
        p11.add(sobrenome1);


        p1.add(p111, BorderLayout.CENTER);
        p111.setLayout(new FlowLayout(FlowLayout.LEFT));
        p111.add(telefone);
        p111.add(telefone1);
        p111.add(endereço);
        p111.add(endereço1);

        p2.setLayout(new FlowLayout(FlowLayout.LEFT));
        p2.add(porcentagem);
        p2.add(porcentagem1);

        p2.add(status);
        p2.add(reservada);
        p2.add(confirmada);
        p2.add(cancelada);

        p2.add(dataE);
        p2.add(dataEN);
        p2.add(dataS);
        p2.add(dataSA);
        p2.add(pesquisar);
        p2.add(listar);

        p3.setLayout(new BorderLayout(1, 1));
        p3.add(new JScrollPane(tquarto), BorderLayout.CENTER);
        p3.add(p4, BorderLayout.SOUTH);
        p4.setLayout(new FlowLayout(FlowLayout.CENTER));

        p4.add(addquarto);
        p4.add(retirarQ);

        p4.add(atualizar);
        fechar.addActionListener(this);
        p4.add(fechar);



        this.setVisible(true);


    }

    public void actionPerformed(ActionEvent e) {
       dispose();
    }

    public void mouseClicked(MouseEvent e) {

        if (e.getSource() == reservada) {
            if (reservada.isSelected()) {
                reservada.setSelected(true);
                cancelada.setSelected(false);
                confirmada.setSelected(false);
                
            } else {
                reservada.setSelected(true);
                cancelada.setSelected(false);
                confirmada.setSelected(false);
            }
        }
        if (e.getSource() == cancelada) {

            if (cancelada.isSelected()) {

                cancelada.setSelected(true);
                confirmada.setSelected(false);
                reservada.setSelected(false);
          
            } else {
                 cancelada.setSelected(true);
                confirmada.setSelected(false);
                reservada.setSelected(false);
            }

        }
        if (e.getSource() == confirmada) {
            if (confirmada.isSelected()) {
                 reservada.setSelected(false);
                cancelada.setSelected(false);
                confirmada.setSelected(true);
             
            } else {
                confirmada.setSelected(true);
                cancelada.setSelected(false);
                reservada.setSelected(false);
            }

        }

    }

    public void mousePressed(MouseEvent e) {
       

    }

    public void mouseReleased(MouseEvent e) {
        
    }

    public void mouseEntered(MouseEvent e) {
       
    }

    public void mouseExited(MouseEvent e) {
        
    }
}


